const express = require("express")

const verifyFn = require("../middleware/loginVerify")

const noteModel = require("../database/model/notebook")
const pageRouter = express.Router()

pageRouter.get("/",(req,res)=>{
    // userModel.find()
    // let {} = data
    let username = req.session.username
    noteModel.find({username},(err,data)=>{
        res.render("index.html",{username,data})
    })
    
    
})

pageRouter.get("/user",(req,res)=>{
    res.render("user.html")
})

pageRouter.get("/center1",verifyFn, (req, res) => {
    let username = req.session.username
    res.render("center.html",{username})

})

pageRouter.get("/center",(req,res)=>{
    res.render("admin.html")
})
    
    
   


pageRouter.get("/logout",verifyFn,(req,res)=>{
    req.session.destroy(()=>{
        res.render("logoutSuccess.html")
    })
})


pageRouter.get("/logon",(req,res)=>{
    res.render("logon.html")
})



module.exports = pageRouter